package com.yzmoney.common.util;

import com.yzmoney.common.model.ObjectId;
import org.apache.commons.lang3.StringUtils;

import java.util.UUID;

/**
 * Created by LiuJun on 2015/7/1.
 */
public class IDUtils {

    /**
     * Mongodb的ObjectId
     * 4字节：UNIX时间戳 3字节：表示运行MongoDB的机器 2字节：表示生成此_id的进程 3字节：由一个随机数开始的计数器生成的值
     *
     * @return
     */
    public static String getObjectId() {
        ObjectId oid = new ObjectId();
        return oid.toString();
    }

    public static String getUUID() {
        UUID uuid = UUID.randomUUID();
        return StringUtils.replace(uuid.toString(), "-", "");
    }

    public static void main(String[] args) {
        System.out.println(getObjectId());
    }
}
